﻿using Maticsoft.BLL;
using Sunny.UI.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UI
{
    public partial class Form2 : Form
    {
        Maticsoft.BLL.Users users = new Maticsoft.BLL.Users();
        public Form2()
        {
            InitializeComponent();
        }

        private void uiHeaderButton1_Click(object sender, EventArgs e)
        {
            int ID = int.Parse(uiTextBox1.Text);
            if(users.Exists(int.Parse(uiTextBox1.Text)));
            {
                Maticsoft.Model.Users users1 = users.GetModel(ID);
                // 把当前登录的用户保存到静态类LoginInfo的静态属性CurrentUser上。
                LoginInfo.CurrentUser = users1;
                if (users1.Password == uiTextBox2.Text && users1.Account == uiTextBox3.Text)
                {
                   
                    DialogResult = DialogResult.OK;
                    MessageBox.Show("登录成功！,在张氏银行，财富只是数字", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    //Form1 form1 = new Form1();
                }
                else
                {
                    MessageBox.Show("不存在该用户");
                }
            }
        }
    }
    public static class LoginInfo
    {
        public static Maticsoft.Model.Users CurrentUser { get; set; } = new Maticsoft.Model.Users();
    }
}
